package com.yanqu.road.dataHelper.action;

import com.yanqu.road.dataHelper.action.excel.CookBoy2;
import com.yanqu.road.dataHelper.gameServer.GameServer;
import com.yanqu.road.dataHelper.manager.ServerMgr;
import com.yanqu.road.entity.servercenter.ServerInfo;
import com.yanqu.road.utils.string.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;


public class CookBoyExcel extends actionBase{
    public void go(List<Long> serverList){
        ExecutorService executorService = Executors.newFixedThreadPool(2);
        List<Future> futureList = new ArrayList<>();
        String activityIdStr = "9063734,9063735,9063736,9063737,9063738,9063739,9063740,9063741,9063742,9063743,9063744,9063745";
        List<Integer> activityIdList = StringUtils.stringToIntegerList(activityIdStr,",");
        for(int activityId : activityIdList){
            futureList = new ArrayList<>();
            for(Long serverId : serverList){
                if(ServerMgr.getServerInfoList().containsKey(serverId)){
                    ServerInfo serverInfo = ServerMgr.getServerInfoList().get(serverId);
                    Future future = executorService.submit(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            GameServer testGameServer = new GameServer(serverInfo);
                            CookBoy2 cookBoy2 = new CookBoy2(testGameServer);
                            cookBoy2.goAllActivity(activityId);
                            return true;
                        }
                    });
                    futureList.add(future);
                }
            }
            isResult(futureList);
        }
        System.err.println("``````===========================================完成");
    }
}
